using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using System.Web.Http;
using WLYT.Admin.WebApi.Models;
using WLYT.Application.Interfaces;
using WLYT.Domain.Model;

namespace WLYT.Admin.WebApi.Controllers
{
    [System.Web.Http.Description.ApiExplorerSettings(IgnoreApi = true)]
    public class AgvPointMapController : BaseController
    {
        private readonly IAgvPointMapService AgvPointMapService;

        public AgvPointMapController(IAgvPointMapService _nameService)
        {
            AgvPointMapService = _nameService;
        }

        [HttpGet]
        [Route("api/AgvPointMap/GetData")]
        public async Task<Table<AgvPointMap>> GetData(string code, int? type, int pageSize, int pageIndex)
        {
            var response = await AgvPointMapService.GetModelsByPageAsync(code, type, pageSize, pageIndex);
            return new Table<AgvPointMap>(response.Item1, response.Item2);
        }

        [HttpGet]
        [Route("api/AgvPointMap/GetModel")]
        public Task<AgvPointMap> GetModel(int id)
        {
            return AgvPointMapService.GetByIdAsync(id);
        }

        [HttpPost]
        [Route("api/AgvPointMap/Save")]
        public Task<bool> Save(ModelRequest<AgvPointMap> request)
        {
            return AgvPointMapService.Save(request.Model);
        }

        [Route("api/AgvPointMap/Remove")]
        public Task<bool> Remove(int id)
        {
            return AgvPointMapService.DeleteAsync(id);
        }

        [HttpPost]
        [Route("api/AgvPointMap/BatchAdd")]
        public Task<bool> BatchAdd(ModelRequest<AgvPointMap> request)
        {
            return AgvPointMapService.BatchAdd(request.List);
        }

        [HttpPost]
        [Route("api/AgvPointMap/BatchDel")]
        public async Task<object> BatchDel(string ids)
        {
            var response = await AgvPointMapService.DeleteAsync(ids);
            return new { Success = response };
        }

        [HttpGet]
        [Route("api/AgvPointMap/GetAll")]
        public Task<object> GetAll()
        {
            return AgvPointMapService.GetAll();
        }

        [HttpGet]
        [Route("api/AgvPointMap/GetFrom")]
        public Task<object> GetFrom()
        {
            return AgvPointMapService.GetFrom();
        }
    }
}